/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pengendali;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import model.Yudisium;
import tabelmodel.TabelModelYudisium;

/**
 *
 * @author admin
 */
public class PengendaliPemeriksaanYudisium {

    public static List<Yudisium> daftarPeriode(javax.swing.JTextField tglAwal, javax.swing.JTextField tglAkhir) {
        List<Yudisium> content = new ArrayList<Yudisium>();
        try {
            java.sql.Date mulai = java.sql.Date.valueOf(tglAwal.getText());
            java.sql.Date akhir = java.sql.Date.valueOf(tglAkhir.getText());
            ResultSet rs = Yudisium.getDaftarPeserta(mulai, akhir);
            while (rs.next()) {
                Yudisium baru = new Yudisium();
                baru.setNim(rs.getString(1));
                baru.setNama(rs.getString(2));
                baru.setProdi(rs.getString(3));
                baru.setNomor_hp(rs.getString(4));
                baru.setPeriode_yudisium(rs.getDate(5));
                baru.setDaftar_nilai(rs.getBoolean(6));
                baru.setNaskah_ta(rs.getBoolean(7));
                baru.setBebas_pinjam_lab(rs.getBoolean(8));
                baru.setBebas_pinjam_dos(rs.getBoolean(9));
                baru.setPenyerahan_KP(rs.getBoolean(10));
                baru.setKeterangan_kkl(rs.getBoolean(11));
                content.add(baru);
            }
            return content;
        } catch (SQLException ex) {
            Logger.getLogger(PengendaliPemeriksaanYudisium.class.getName()).log(Level.SEVERE, null, ex);
            return content;
        } catch (java.lang.IllegalArgumentException ex) {
            JOptionPane.showMessageDialog(null, ex + "Format tanggal salah.");
            Logger.getLogger(PengendaliPendaftaranYudisium.class.getName()).log(Level.SEVERE, null, ex);
            return content;
        }

    }

    public static void ubahKelengkapan(javax.swing.JCheckBox bNilai, javax.swing.JCheckBox bTa,
            javax.swing.JCheckBox bBebasLeb, javax.swing.JCheckBox bBebasSDoden, javax.swing.JCheckBox bKP,
            javax.swing.JCheckBox bKKL, TabelModelYudisium tabelModelYudisium, javax.swing.JTable tbData) {
        try {
            Yudisium yudLama = tabelModelYudisium.getYudisium(tbData.getSelectedRow());
            Yudisium yudBaru = new Yudisium();
            yudBaru.setNim(tabelModelYudisium.getYudisium(tbData.getSelectedRow()).getNim());
            yudBaru.setNama(tabelModelYudisium.getYudisium(tbData.getSelectedRow()).getNama());
            yudBaru.setProdi(tabelModelYudisium.getYudisium(tbData.getSelectedRow()).getProdi());
            yudBaru.setNomor_hp(tabelModelYudisium.getYudisium(tbData.getSelectedRow()).getNomor_hp());
            yudBaru.setPeriode_yudisium(tabelModelYudisium.getYudisium(tbData.getSelectedRow()).getPeriode_yudisium());
            yudBaru.setDaftar_nilai(bNilai.isSelected());
            yudBaru.setNaskah_ta(bTa.isSelected());
            yudBaru.setBebas_pinjam_lab(bBebasLeb.isSelected());
            yudBaru.setBebas_pinjam_dos(bBebasSDoden.isSelected());
            yudBaru.setPenyerahan_KP(bKP.isSelected());
            yudBaru.setKeterangan_kkl(bKKL.isSelected());
            Yudisium.editKelengkapanYudisium(yudBaru, yudLama);
            JOptionPane.showMessageDialog(null, "Konfirmasi data telah diubah.");
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, "Konfirmasi data gagal diubah.");
            Logger.getLogger(PengendaliPemeriksaanYudisium.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

}
